package io.springboot.jpa.examples.springbootjpaexamples.model;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author yzc
 * @description
 * @date 2018/9/7
 */
@Entity
@Table(name = "enterprise")
public class Enterprise extends BaseBean implements Serializable {

    private static final long serialVersionUID = 8871695683311024515L;

    private String name;
    private String legalPerson;
    private String unCreditCode;
    private String organizationCode;
    private String businessLicenseNo;
    private String taxRegistrationNo;
    private String address;
    private String phoneNumber;
    private String bankName;
    private String account;

    private Organization organization;
    private List<Seal> sealList = new ArrayList<>();
    private List<Certificate> certificateList = new ArrayList<>();

    @Column(name = "name", length = 50, unique = true)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "legal_person", length = 10)
    public String getLegalPerson() {
        return legalPerson;
    }

    public void setLegalPerson(String legalPerson) {
        this.legalPerson = legalPerson;
    }

    @Column(name = "unified_social_credit_code", length = 20, unique = true)
    public String getUnCreditCode() {
        return unCreditCode;
    }

    public void setUnCreditCode(String unCreditCode) {
        this.unCreditCode = unCreditCode;
    }

    @Column(name = "organization_code", length = 20, unique = true)
    public String getOrganizationCode() {
        return organizationCode;
    }

    public void setOrganizationCode(String organizationCode) {
        this.organizationCode = organizationCode;
    }

    @Column(name = "business_license_registration_number", length = 20, unique = true)
    public String getBusinessLicenseNo() {
        return businessLicenseNo;
    }

    public void setBusinessLicenseNo(String businessLicenseNo) {
        this.businessLicenseNo = businessLicenseNo;
    }

    @Column(name = "tax_registration_number", length = 20, unique = true)
    public String getTaxRegistrationNo() {
        return taxRegistrationNo;
    }

    public void setTaxRegistrationNo(String taxRegistrationNo) {
        this.taxRegistrationNo = taxRegistrationNo;
    }

    @Column(name = "address", length = 50)
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Column(name = "phone_number", length = 15)
    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    @Column(name = "bank_name", length = 50)
    public String getBankName() {
        return bankName;
    }

    public void setBankName(String bankName) {
        this.bankName = bankName;
    }

    @Column(name = "account", length = 30)
    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    @ManyToOne
    @JoinColumn(name = "organization_id")
    public Organization getOrganization() {
        return organization;
    }

    public void setOrganization(Organization organization) {
        this.organization = organization;
    }

    @JsonIgnore
    @OneToMany
    @JoinColumn(name = "enterprise_id") // 会在Seal表中增加一列enterprise_id做为外键
    public List<Seal> getSealList() {
        return sealList;
    }

    public void setSealList(List<Seal> sealList) {
        this.sealList = sealList;
    }

    @JsonIgnore
    @OneToMany
    @JoinColumn(name = "enterprise_id")
    public List<Certificate> getCertificateList() {
        return certificateList;
    }

    public void setCertificateList(List<Certificate> certificateList) {
        this.certificateList = certificateList;
    }
}
